package cn.wolfcode.shop.result;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * Created by wolfcode-lanxw
 */
@Setter@Getter
public class CodeMsg implements Serializable {



    private int code;
    private String msg;
    private CodeMsg(int code,String msg){
        this.code = code;
        this.msg = msg;
    }
    //系统模块
    public static CodeMsg SUCCESS = new CodeMsg(200,"success");

    //系统异常
    public static CodeMsg SERVER_ERROR = new CodeMsg(500001,"系统异常");
    //用户模块
    public static final CodeMsg MOBILE_EMPTY = new CodeMsg(500100,"手机号码不能为空");
    public static final CodeMsg PASSWORD_EMPTY = new CodeMsg(500101,"密码不能为空");
    public static final CodeMsg MOBILE_INVAILD = new CodeMsg(500102,"手机号码格式不正确");
    public static final CodeMsg LOGIN_ERROR = new CodeMsg(500103,"账号密码有误");
    public static final CodeMsg LOGIN_INVAILD = new CodeMsg(500104,"登录信息过期");
    //参数绑定异常
    public static final CodeMsg BIND_ERROR = new CodeMsg(500200,"参数校验异常:%s");

    //秒杀模块
    public static final CodeMsg ILLEGAL_OP = new CodeMsg(500300,"非法操作");
    public static final CodeMsg STOCK_OVER = new CodeMsg(500301,"商品已被抢购完了.");
    public static final CodeMsg SECKILL_REPEAT = new CodeMsg(500302,"不能重复秒杀");
    public static final CodeMsg SECKILL_ERROR = new CodeMsg(500303,"秒杀失败");
    public static final CodeMsg VERIFYCODE_ERROR = new CodeMsg(500304,"验证码有误");;
    public static final CodeMsg ACCESS_LIMIT_ERROR = new CodeMsg(500305,"访问太频繁");;;
    public static final CodeMsg ORDER_SUCCESS = new CodeMsg(200,"%s");

    public CodeMsg fillArgs(Object...args){
        this.msg = String.format(this.msg,args);
        return this;
    }
}
